package cn.cheln.explorer.cpnt.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;


import cn.cheln.explorer.beans.FileInfo;
import cn.cheln.explorer.config.Constants;
import cn.cheln.support.ui.adapter.MapAdapter;
import cn.cheln.support.images.FileIconHelper;

public class ThumbnailAdapter extends MapAdapter {

    public FileIconHelper fileIconHelper;

    public ThumbnailAdapter(Context context, AdaptInfo listViewHolder) {
        super(context, listViewHolder);
        fileIconHelper = new FileIconHelper(context);
    }
    int iconViewId = -1;
    @Override
    protected void findAndBindView(View convertView, int pos, Object item,
            String name, Object value) {
        // TODO Auto-generated method stub
        if (name.equals(Constants.FieldConstants.ICON_RES)) {
            if (value.toString().equals("-1")) {
                if(iconViewId == -1){
                    iconViewId = this.viewsid[this.fieldnames.indexOf(name)];
                }
                fileIconHelper.setIcon(getThumbnailBase((FileInfo) item), (ImageView) convertView.findViewById(iconViewId));
            }
        }
        super.findAndBindView(convertView, pos, item, name, value);
    }

    protected FileInfo getThumbnailBase(FileInfo fileInfo) {
        return fileInfo;
    }
}
